package com.ruoyi.food.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.food.mapper.TRectInfoMapper;
import com.ruoyi.food.object.TRectInfo;
import com.ruoyi.food.service.TRectInfoService;

@Service
public class TRectInfoServiceImpl extends ServiceImpl<TRectInfoMapper, TRectInfo> implements TRectInfoService {

	@Autowired
	private TRectInfoMapper tRectInfoMapper;
	
	@Override
	public int saveTRectInfo(List<TRectInfo> tRectInfos) {
		// TODO Auto-generated method stub
		int sign = 1;
		if(!tRectInfos.isEmpty()) {
			try {
				//this.saveBatch(tRectInfos);
				for(TRectInfo tRectInfo:tRectInfos) {
					tRectInfoMapper.insertTRectInfo(tRectInfo);
				}				
			}catch(Exception e) {
				sign=0;
			}
		}else {
			sign=0;
		}
		return sign;

	}

	public List<TRectInfo> findTRectInfo(TRectInfo tRectInfo) {
		// TODO Auto-generated method stub
		return tRectInfoMapper.selectTRectInfo(tRectInfo);
	}

	@Override
	public int updateTRectInfo(TRectInfo tRectInfo) {
		// TODO Auto-generated method stub
		int sign=1;
		try {
			tRectInfoMapper.updateTRectInfo(tRectInfo);
		}catch(Exception e) {
			sign=0;
		}
		return sign;
	}

	@Override
	public TRectInfo findTRectInfoById(long rectId) {
		// TODO Auto-generated method stub
		return tRectInfoMapper.selectTRectInfoById(rectId);
	}

	@Override
	public int deleteTRectInfo(long rectId) {
		// TODO Auto-generated method stub
		int sign=1;
		try {
			tRectInfoMapper.deleteTRectInfo(rectId);
		}catch(Exception e) {
			sign=0;
		}
		return sign;
	}

	@Override
	public List<TRectInfo> findAllTRectInfo() {
		// TODO Auto-generated method stub
		return tRectInfoMapper.selectAllTRectInfo();
	}

}
